<template>
  <svg :style="className" class="svg-icon" aria-hidden="true" @click="clickIcon">
    <use :xlink:href="iconName"></use>
  </svg>
</template>

<script>
export default {
  name: 'SvgIcon',
  props: {
    icon: {
      type: String,
      required: true,
    },
    className: {
      type: Object,
      default: {},
    },
  },
  computed: {
    iconName() {
      return `#${this.icon}`
    }
  },
  methods: {
    clickIcon() {
      this.$emit('click');
    }
  }
}
</script>

<style scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>